import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:使用Scanner来辅助读取文件
 * Scanner(System.in)括号里的System.in本质上就是一个InputStream
 * Author: WJW
 * Date: 2024-08-20
 * Time: 22:46
 */
public class IODemo6 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("./test.txt")){
            Scanner scanner = new Scanner(inputStream);
            while (scanner.hasNext()){
                String s = scanner.next();
                System.out.println(s);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
